<template>
  <x-tree
    ref="setTree"
    @changeTree="handleChangeTree"
    @treeCheck="handleTreeCheck"
    :checkable="checkable"
    :treeData="treeData"
  ></x-tree>
</template>

<script>
import XTree from '@/components/ETree'
import { getDeptTree } from '@/api/department'

export default {
  components: {
    XTree
  },
  props: {
    checkable: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      treeData: []
    }
  },
  mounted() {
    this.getDeptTree()
  },
  methods: {
    getKeys(arr) {
      console.log('dept tree', arr)
      this.$refs.setTree.getKeys(arr)
    },
    getDeptTree() {
      getDeptTree().then(res => {
        this.treeData = res.data
      })
    },
    handleTreeCheck(arr) {
      this.$emit('treeCheck', arr)
    },
    handleChangeTree(obj) {
      this.$emit('changeTree', obj)
    }
  }
}
</script>

<style>
</style>